const $public = require("public.js");
// 获取充值订单列表
// let addr ='https://www.yulonging.com/dwweb/wxapi.ashx'//正式服
let addr ='https://www.yulonging.com/dwweb/wxapi.ashx'//测试服
let officeId=1
// ============================================
// =================轮播图广告==================
//newbanner
const getBanner = function(data) {
  let promise = new Promise((resolve, reject) => {
    let port = `?cmd=getbanners&officeId=${officeId}`
    $public.wxAjax(addr, port, "get", data, ).then(res => {
      if (res.STATUS == 'Success') {
        resolve(res);
      } else {
        reject(res);
      }
    })
  })
  return promise;
}
// =================获取会议室列表==================
//getMeetRooms
const getMeetRooms = function(data) {
  let promise = new Promise((resolve, reject) => {
    let port = `?cmd=getMeetRooms&officeId=${officeId}`
    $public.wxAjax(addr, port, "get", data, ).then(res => {
      if (res.STATUS == 'Success') {
        resolve(res);
      } else {
        reject(res);
      }
    })
  })
  return promise;
}
// ================获取会议室基本信息=================
// getRoomInfo
const getRoomInfo = function(data) {
  let promise = new Promise((resolve, reject) => {
    let port = `?cmd=getRoomInfo`
    $public.wxAjax(addr, port, "get", data, ).then(res => {
      if (res.STATUS == 'Success') {
        resolve(res);
      } else {
        reject(res);
      }
    })
  })
  return promise;
}
// ===========获取某会议室某天可订时段与价格============
// GetRoomTimesInfo
const getRoomTimesInfo = function(data) {
  let promise = new Promise((resolve, reject) => {
    let port = `?cmd=GetRoomTimesInfo`
    $public.wxAjax(addr, port, "get", data, ).then(res => {
      if (res.STATUS == 'Success') {
        resolve(res);
      } else {
        reject(res);
      }
    })
  })
  return promise;
}
// ===========获取某会议室配套============
// getGoodsList
const getGoodsList = function(data) {
  let promise = new Promise((resolve, reject) => {
    let port = `?cmd=getGoodsList&officeId=${officeId}`
    $public.wxAjax(addr, port, "get", data, ).then(res => {
      if (res.STATUS == 'Success') {
        resolve(res);
      } else {
        reject(res);
      }
    })
  })
  return promise;
}


// ===========获取某会议室配套============
// wxlogin
const wxlogin = function(data) {
  let promise = new Promise((resolve, reject) => {
    let port = `?cmd=wxlogin&officeId=${officeId}`
    $public.wxAjax(addr, port, "get", data, ).then(res => {
      if (res.STATUS == 'Success') {
        resolve(res);
      } else {
        reject(res);
      }
    })
  })
  return promise;
}

// ===========保存订单============
// SaveOrder
const saveOrder = function(data) {
  let promise = new Promise((resolve, reject) => {
    console.log('test')
    let port = `?cmd=saveOrder`
    $public.wxAjax(addr, port, "post", data, ).then(res => {
      if (res.STATUS == 'Success') {
        resolve(res);
      } else {
        reject(res);
      }
    })
  })
  return promise;
}

//GetOrderInfo
const getOrderInfo = function(data) {
  let promise = new Promise((resolve, reject) => {
    console.log('test')
    let port = `?cmd=GetOrderInfo`
    $public.wxAjax(addr, port, "get", data, ).then(res => {
      if (res.STATUS == 'Success') {
        resolve(res);
      } else {
        reject(res);
      }
    })
  })
  return promise;
}




// ============================================
module.exports = {
  getBanner: getBanner, //1.0版本页面使用的接口
  getMeetRooms:getMeetRooms,//获取会议室列表 首页
  getRoomInfo:getRoomInfo,//获取会议室详情 详情页
  getRoomTimesInfo:getRoomTimesInfo,//获取会议室可用时间段
  getGoodsList:getGoodsList,//获取会议室配套商品
  wxlogin:wxlogin,//登录
  saveOrder:saveOrder,//保存订单
  getOrderInfo:getOrderInfo,//获取订单信息
}